package com.example.shop_2305.adapter

import android.widget.CheckBox
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.lib_base.entity.Cart
import com.example.shop_2305.R
import com.example.shop_2305.utils.GlideUtils

class CartAdapter:BaseQuickAdapter<Cart,BaseViewHolder>(R.layout.item_cart) {
    override fun convert(holder: BaseViewHolder, item: Cart) {
        holder.getView<CheckBox>(R.id.cart_cb).isChecked = item.isChecked
        GlideUtils.loadNormal(context,item.image,holder.getView(R.id.cart_image))
        holder.setText(R.id.cart_name,item.storeName)
        holder.setText(R.id.cart_suk,"属性:${item.suk}")
        holder.setText(R.id.cart_price,"￥${item.price}")
        holder.setText(R.id.cart_num,item.cartNum.toString())//不能直接给int
        //当数量为1时  减不可点击
        //holder.getView<TextView>(R.id.cart_sub).isEnabled =  (item.cartNum!=1)

        if(item.cartNum!=1){
            holder.getView<TextView>(R.id.cart_sub).isEnabled = true
        }else{
            holder.getView<TextView>(R.id.cart_sub).isEnabled = false
        }
    }
}